package com.company.test;

import com.company.dao.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.beans.Transient;

@Component
public class A {
    @Autowired  // 自动注入属性
    private UserMapper userMapper;

    @Transactional  // 事务处理，遇到异常自动回滚
    public void a() {
        System.out.println(userMapper.queryByName("tom"));
    }
}
